import request from '@/utils/request'

import type {
  GetTrademarkListApiResponse,
  TrademarkItem,
  TrademarkList
} from './model/trademarkModel'

// 使用枚举定义接口地址
enum Api {
  getTrademarkList = '/admin/product/baseTrademark',
  saveTrademark = '/admin/product/baseTrademark/save',
  updateTrademark = '/admin/product/baseTrademark/update',
  removeTrademark = '/admin/product/baseTrademark/remove',
  getAllTrademarkList = '/admin/product/baseTrademark/getTrademarkList',
}

// 获取品牌分页列表
export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListApiResponse>(
    `${Api.getTrademarkList}/${page}/${limit}`
  )
}

// 添加品牌
export const saveTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.saveTrademark, {
    // 请求体参数
    tmName,
    logoUrl,
  })
}

// 修改品牌
export const updateTrademarkApi = (tm: TrademarkItem) => {
  return request.put<any, null>(Api.updateTrademark, tm)
}

// 删除品牌
export const removeTrademarkApi = (id: number) => {
  return request.delete<any, null>(`${Api.removeTrademark}/${id}`)
}

// 获取所有品牌列表
export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarkList>(Api.getAllTrademarkList)
}
